<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>子元素margin</title>
    <style>
        .parent {
            display: flow-root;
            background: skyblue;
            height: 40px;
        }

        .child {
            display: flow-root;
            margin: 20px 0;
            height: 100%;
        }
    </style>
</head>

<body>
    <div class="parent">
        <div class="child"></div>
    </div>
    <div class="parent">
        <div class="child"></div>
    </div>
</body>

</html>